package com.naiterui.ehp.bs.doctor.vo;

import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.doctor.exception.ExceptionCodes;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;
import org.springframework.web.multipart.MultipartFile;

import java.io.Serializable;


@ToString
@ApiModel(value = "LicenseParam", description = "资质参数VO")
public class LicenseParam implements Serializable {

    private static final long serialVersionUID = 5637226411863550238L;
    /**
     * 医师执业证号
     */
    @ApiModelProperty(value = "医师执业证号")
    private String number;

    /**
     * 个人照片
     */
    @ApiModelProperty(value = "个人照片")
    private MultipartFile avatar;

    /**
     * 工作证
     */
    @ApiModelProperty(value = "工作证")
    private MultipartFile emCard;

    /**
     * 医师执业证
     */
    @ApiModelProperty(value = "医师执业证")
    private MultipartFile medical;

    /**
     * 医师执业证补充页
     */
    @ApiModelProperty(value = "医师执业证补充页")
    private MultipartFile supplyMedical;

    /**
     * 签章图片
     */
    @ApiModelProperty(value = "签章图片")
    private MultipartFile sealImg;


    /**
     * 参数验证
     */
    public void validate(boolean isAll) throws BusinessException {

        if (isAll) {

            //            if (StringUtils.isBlank(number) || avatar == null || emCard == null || (medical == null && supplyMedical == null || sealImg == null)) {
            //if (StringUtils.isBlank(number) || avatar == null || emCard == null || (medical == null && supplyMedical == null) || (ESignUtils.isHandWriting() && sealImg == null)) {
            if (avatar == null || (medical == null && supplyMedical == null)) {
                throw new BusinessException(ExceptionCodes.PARAM_ERROR);
            }

        } else {
            //            if (StringUtils.isBlank(number) && avatar == null && emCard == null && medical == null && supplyMedical == null && sealImg == null) {
            if (avatar == null && medical == null && supplyMedical == null) {
                throw new BusinessException(ExceptionCodes.PARAM_ERROR);
            }
        }

//        if (StringUtils.isNotBlank(number)) {
//            number = number.replaceAll(" ", "");
//            // 判断执业资格证号是否属于范围内
//            if (number.length() < 1 || number.length() > 27) {
//                throw new BusinessException(ExceptionCodes.PARAM_ERROR_MEDICAL_NUM);
//            }
//        }

    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public MultipartFile getAvatar() {
        return avatar;
    }

    public void setAvatar(MultipartFile avatar) {
        this.avatar = avatar;
    }


    public MultipartFile getMedical() {
        return medical;
    }

    public void setMedical(MultipartFile medical) {
        this.medical = medical;
    }

    public MultipartFile getSupplyMedical() {
        return supplyMedical;
    }

    public void setSupplyMedical(MultipartFile supplyMedical) {
        this.supplyMedical = supplyMedical;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public MultipartFile getSealImg() {
        return sealImg;
    }

    public void setSealImg(MultipartFile sealImg) {
        this.sealImg = sealImg;
    }

    public MultipartFile getEmCard() {
        return emCard;
    }

    public void setEmCard(MultipartFile emCard) {
        this.emCard = emCard;
    }

}
